package com.aaa.ssm.service.impl;

import com.aaa.ssm.dao.DepartmentDao;
import com.aaa.ssm.entity.Department;
import com.aaa.ssm.service.DepartmentService;
import com.aaa.ssm.util.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class DepartmentServiceImpl implements DepartmentService {

    @Resource
    private DepartmentDao departmentDao;

    @Override
    public PageInfo queryByPage(Page<Department> page) {
        //设置分页参数
        PageHelper.startPage(page.getPageNo(),page.getPageSize());
        return new PageInfo<>(departmentDao.queryByParam(page.getData()));
    }

    @Override
    public List<Department> queryByParam(Department department) {
        return departmentDao.queryByParam(department);
    }

    @Override
    public Department queryById(Integer departmentId) {
        return departmentDao.queryById(departmentId);
    }

    @Override
    public int add(Department department) {
        return departmentDao.add(department);
    }

    @Override
    public int update(Department department) {
        return departmentDao.update(department);
    }

    @Override
    public int delete(Integer departmentId) {
        return departmentDao.delete(departmentId);
    }
}
